package boogui.member;


import java.sql.PreparedStatement;
import java.sql.ResultSet;

import boogui.member.db.BooguiDAO;
import boogui.member.db.BooguiDBVO;

/**
 * 중복 검사
 */

public class MemberChkDAO {
	BooguiDAO bdao = null;
	BooguiDBVO bdbvo = null;

	public MemberChkDAO() {
		bdao = new BooguiDAO();
		bdbvo = new BooguiDBVO();
	}

	public boolean chkD(String sql, String val) {
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		boolean result = false;

		try {
			conn = bdao.openDatabase();
			pstmt = conn.prepareStatement(sql);
			pstmt.setString(1, val);
			rs = pstmt.executeQuery();

			if (rs.next()) {
				result = true; // 값이 있으면 true 중복
			} else {
				result = false; // 값이 없으면 false 중복아님
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		} finally {
			bdao.closeDatabase(conn, pstmt, rs);
		}
		return result;
	}

}
